﻿using CMS.BaseEntity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace CMS.DataAccess
{
    public class CategoryAccess
    {
        public DataTable GetListCategory()
        {
            return DataAccess.ExeStoredNonToDataTable("cusp_CategorySelectAll");
        }

        public bool IsInsertedCategory(Category category)
        {
            return DataAccess.ExeStoredWithParamToBool(
                "cusp_CategoryInsert",
                "@SectionId", category.SectionId,
                "@AuthorId", category.AuthorId,
                "@CategoryName", category.CategoryName,
                "@Description", category.Description,
                "@CreateDate", category.CreateDate,
                "@Enable", category.Enable);
        }

        public bool IsUpdatedCategory(Category category)
        {
            return DataAccess.ExeStoredWithParamToBool(
                "cusp_CategoryUpDate",
                "@CategoryId", category.CategoryId,
                "@SectionId", category.SectionId,
                "@AuthorId", category.AuthorId,
                "@CategoryName", category.CategoryName,
                "@Description", category.Description,
                "@LastModify", category.LastModify,
                "@Enable", category.Enable);
        }

        public DataTable GetCategoryById(Category category)
        {
            return DataAccess.ExeStoredWithParamToDataTable(
                "cusp_CategorySelectByID",
                "@CategoryId", category.CategoryId);
        }

        public bool IsDeletedCategory(Category category)
        {
            return DataAccess.ExeStoredWithParamToBool(
                "cusp_CategoryDelete",
                "@CategoryId", category.CategoryId);
        }

        /// <summary>
        /// lấy thể loại theo từng chuyên mục post lên dropdown
        /// </summary>
        /// <returns></returns>
        public DataTable GetListCateBySection(Category category)
        {
            return DataAccess.ExeStoredWithParamToDataTable(
                "cusp_CategorySelectBySection",
                "@SectionId", category.SectionId
                );
        }
    }
}